package learn.design.patterns.E_Builder.BuilderWithStaticNestedClass;

import lombok.Getter;

//静态内部类建造者模式（Builder with Static Nested Class）
@Getter
public class StaticComputer {
    private final String processor;
    private final String ram;
    private final String hardDrive;

    private StaticComputer(ComputerBuilder builder) {
        this.processor = builder.processor;
        this.ram = builder.ram;
        this.hardDrive = builder.hardDrive;
    }

    public static class ComputerBuilder {
        private String processor;
        private String ram;
        private String hardDrive;

        public ComputerBuilder withProcessor(String processor) {
            this.processor = processor;
            return this;
        }

        public ComputerBuilder withRam(String ram) {
            this.ram = ram;
            return this;
        }

        public ComputerBuilder withHardDrive(String hardDrive) {
            this.hardDrive = hardDrive;
            return this;
        }

        public StaticComputer build() {
            return new StaticComputer(this);
        }
    }

}
